<script>
import {mapGetters} from "vuex";

export default {
  name: "corporationInfo",
  data() {
    return {
      info: '对公司名称、公司地址、营业执照、公司地区的更新，将使得公司资料被重新审核，请谨慎修改',
      /* 企业的信息 */
      companyInfo: {}
    }
  },
  methods: {
    /* findCompany()函数的作用用于根据公司的id派发一个action去发送请求获取企业信息 */
    async findCompany() {
      try {
        const companyInfo = await this.$store.dispatch('settingsStore/findCompanyDetail', this.companyId)
        this.companyInfo = companyInfo
      } catch (error) {
        this.$message.error(error.message)
      }
    },
  },
  computed: {
    /* 使用mapGetters将getters中的数据映射为组件实例的属性 */
    ...mapGetters(['companyId'])
  },
  mounted() {
    /* 组件挂载完毕调用indCompany()去派发action获取企业信息 */
    this.findCompany()
  }
}
</script>

<template>
  <div class="corporationInfo">
    <el-alert type="info" show-icon :title="info"></el-alert>
    <el-form label-width="100px" ref="form">
      <el-form-item label="公司名称">
        <el-input v-model="companyInfo.name" disabled></el-input>
      </el-form-item>
      <el-form-item label="公司地址">
        <el-input v-model="companyInfo.companyAddress" disabled></el-input>
      </el-form-item>
      <el-form-item label="公司邮箱">
        <el-input v-model="companyInfo.mailbox" disabled></el-input>
      </el-form-item>
      <el-form-item label="公司电话">
        <el-input v-model="companyInfo.companyPhone" disabled></el-input>
      </el-form-item>
      <el-form-item label="创建时间">
        <el-date-picker v-model="companyInfo.createTime" type="date" disabled></el-date-picker>
      </el-form-item>
      <el-form-item label="公司备注">
        <el-input type="textarea" resize="none" rows="4" v-model="companyInfo.remarks" disabled></el-input>
      </el-form-item>
    </el-form>
  </div>
</template>

<style scoped lang="scss">
.corporationInfo {
  .el-form {
    width: 25%;
    margin-top: 40px;
  }
}
</style>
